#!/usr/bin/python
import sys
import re
from filmset import MyVideo
def readFile(filename):
    myVideo = MyVideo("file:"+filename)
    f = open(filename)
    comment = re.compile('^#')
    line = f.readline()
    while line:
        d = comment.findall(line)
        if len(d)<1:
            myVideo.addplayer(line)
        line = f.readline()
    f.close()
    return myVideo
# Script starts from here
if len(sys.argv) < 2:
    print 'No action specified.'
elif sys.argv[1].startswith('--'):
   option = sys.argv[1][2:]
   # fetch sys.argv[1] but without the first two characters
   if option == 'version':
      print 'Version 0.1'
   elif option == 'file':
      myvideo = readFile(sys.argv[2])
      myvideo.download()
   elif option == 'help':
      print '''
This program prints files to the standard output.
Any number of files can be specified.
Options include:
--file    : Download from m3u file
--version : Prints the version number
--help    : Display this help'''
   else:
       print 'Unknown option.'
sys.exit();
